package com.bawei.rk_01

import android.annotation.SuppressLint
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.core.view.isVisible
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.base.utils.mvvm.BaseViewActivity
import com.bawei.rk_01.databinding.ActivityWebBinding

@Route(path = "/app/WebActivity")

class WebActivity : BaseViewActivity<ActivityWebBinding>() {

    @JvmField
    @Autowired
    var url = ""

    override fun getLayout(): Int {
        return R.layout.activity_web
    }

    @SuppressLint("SetJavaScriptEnabled")
    override fun initView() {

        ARouter.getInstance().inject(this)

        binding.web.webChromeClient = object : WebChromeClient() {
            override fun onProgressChanged(view: WebView?, newProgress: Int) {
                super.onProgressChanged(view, newProgress)
                if (newProgress == 100){
                    binding.pro.isVisible = false
                }
                binding.pro.progress = newProgress
            }
        }

        binding.web.loadUrl(url)
        binding.web.webViewClient = WebViewClient()
        binding.web.settings.javaScriptEnabled = true

    }

    override fun initData() {

    }

}